package practice;

import java.io.File;
import java.io.FileFilter;

public class Demo02FileFilter {
    public static void main(String[] args) {
//        FileFilter filter = new FileFilter() {
//            @Override
//            public boolean accept(File pathname) {
//                String name = pathname.getName();
//                return name.contains("g");
//            }
//        };
//        File dir = new File(".");
//        File[] list = dir.listFiles(filter);
//        for (int i = 0; i < list.length; i++) {
//            File f=list[i];
//            System.out.println(f.getName());
//        }
        /*FileFilter filter =pathname-> pathname.getName().contains("g");


        File dir = new File(".");
        File[] list = dir.listFiles(filter);
        for (int i = 0; i < list.length; i++) {
            File f=list[i];
            System.out.println(f.getName());
        }*/
        FileFilter filter=pathname -> pathname.getName().startsWith("f");
        File file=new File(".");
        File[]frr=file.listFiles(filter);
        for (int i = 0; i < frr.length; i++) {
            System.out.println(frr[i].getName());
        }
    }
}